{% extends 'base_backend.html' %}
{% load static %}
{% load my_filter %}

{% block header_tail %}
<link rel="stylesheet" href="{% static 'zhongbao/zhongbao_admin/css/style.css' %}">
<link rel="stylesheet" href="{% static 'zhongbao/zhongbao_admin/css/iconfont.css' %}">
<link rel="stylesheet" href="{% static 'plugins/datatables/dataTables.bootstrap.css' %}">
<link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
<link rel="stylesheet" href="{% static 'zhongbao/config/css/main.css' %}">

<script src="{% static 'plugins\jQuery\jquery-2.2.3.min.js' %}"></script>

<script src="{% static 'plugins/vue1/vue.js' %}"></script>

<script src="{% static 'enjoyhint/js/enjoyhint.min.js' %}"></script>
<link rel="stylesheet" href="{% static 'enjoyhint/css/enjoyhint.css' %}">
{% endblock header_tail %}

{% block section_content %}
<div class="col-md-12 column">
    <div class="row">
        <div class="col-sm-12">
            <h3>链接查询</h3>
        </div>
    </div>
    <div class="col-md-12">
        <form action="">
            <div class="col-sm-10 col-sm-offset-1" style="height: 80px;background: #F0F0F0;margin-top: 20px">
                <div class="input-group col-sm-12">
                    <input id="cha" type="text" class="form-control " name="url" placeholder="输入链接或域名(子域名查询)" value="{{ fqdn }}"
                           style="margin:15px 0 15px;height: 50px;border-radius:0 0 0 0; font-size: 16px">
                    <span class="input-group-btn">
                        <button type="submit" class="btn btn-primary btn-lg btn-block" id="btn_search"
                                style="height:50px;border-radius:0 0 0 0;">
                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                            <span id="cha_span" class="tran">&nbsp;查一下</span>
                        </button>
                    </span>
                </div>
<!--                <div class="col-sm-11 col-sm-offset-1">-->
<!--                    <span id="message1">提取到一级域名:hljtv.com 提取到二级域名:zmt-m.hljtv.com</span>-->
<!--                </div>-->
            </div>
        </form>
        {% if not config_list %}
        {% else %}
        <div class="col-sm-10 col-sm-offset-1" style="margin-top: 50px;">
            <h5>采集后台：</h5>
            <table class="table table-striped table-hover table-condensed"
                   style="text-align: center;border-collapse: collapse;">
                <tbody>
                <tr style="border: 2px solid #e5e5e5;">
                    <td style="vertical-align:middle;">
                        <a href="http://ispider.istarshine.com/config/{{ config.config_id }}/change/">配置ID</a>
                    </td>
                    <td style="vertical-align:middle;">网站名称</td>
                     <td style="vertical-align:middle;">作者</td>
                     <td style="vertical-align:middle;">文件名</td>
                     <td style="vertical-align:middle;">备案号</td>
                     <td style="vertical-align:middle;">分组</td>
                     <td style="vertical-align:middle;">国家</td>
                     <td style="vertical-align:middle;">语言</td>
                     <td style="vertical-align:middle;">是否启用</td>
                     <td style="vertical-align:middle;">
                         <a href="http://zhongbao.istarshine.com/task/detail?id={{ config.zb_id }}&type=task&user=admin">众包任务ID</a>
                     </td>
                </tr>
                {% for config in config_list %}
                <tr class="add" id="caiji" style="border: 1px solid #e5e5e5;">
                    <td style="vertical-align:middle;">
                        <a href="http://ispider.istarshine.com/config/{{ config.config_id }}/change/" target="_blank">
                            {{ config.config_id }}
                        </a>
                    </td>
                    <td style="vertical-align:middle;">{{ config.webname }}</td>
                     <td style="vertical-align:middle;">{{ config.author }}</td>
                     <td style="vertical-align:middle;">{{ config.savename }}</td>
                     <td style="vertical-align:middle;">{{ config.icp }}</td>
                     <td style="vertical-align:middle;">{{ config.group.group_name }}</td>
                     <td style="vertical-align:middle;">{{ config.country.country }}</td>
                     <td style="vertical-align:middle;">{{ config.lang.lang }}</td>
                    {% if config.is_running == 0 %}
                     <td style="vertical-align:middle; background: red">未启用</td>
                    {% elif config.is_running == 1 %}
                    <td style="vertical-align:middle;">启用</td>
                    {% else %}
                    <td style="vertical-align:middle;">异常</td>
                    {% endif %}
                     <td style="vertical-align:middle;">
                         <a href="http://zhongbao.istarshine.com/task/detail?id={{ config.zb_id }}&type=task&user=admin" target="_blank">
                             {{ config.zb_id }}
                         </a>
                     </td>
                </tr>
                {% endfor %}

                </tbody>
            </table>
        </div>
        {% endif %}
    </div>

    <script type="text/Javascript">
        var mainVue = new Vue({
            delimiters: ['[[', ']]'],
            el: '.col-md-12',
            data: {
                data_cj_list: [],
                data_zb_list: [],
                text: '',
            },
        });

        $(document).ready(function () {

        });

        $('#btn_search').click(function () {
            var text = $("input[ name='text']").val();
            if (text) {
                mainVue.text = text;
                deploy_query()
            }
        });
        $('#cha').bind('keyup', function (event) {
            if (event.keyCode == "13") {
                var text = $("input[ name='text']").val();
                if (text) {
                    mainVue.text = text;
                    deploy_query()
                }
            }
        });

        function deploy_query() {
            mainVue.data_cj_list = [];
            mainVue.data_zb_list = [];
            if (mainVue.text) {
                $.ajaxSetup({
                    data: {
                        csrfmiddlewaretoken: 'GRipnt4xBGj4xPxts4Z5eId3rvzPGX4u1Dn7nfH6L9O0OdHIjV5QE8wjaoRQ3lw3',
                        'text': mainVue.text,
                    }
                });
                $.post(
                    "/information/url_query/",
                    function (response) {
                        var message = response.message;
                        var message1 = response.message1;
                        $('#message1').text(message1);
                        if (message === 'ok') {
                            mainVue.data_cj_list = response.data_cj_list;
                            mainVue.data_zb_list = response.data_zb_list;
                        } else {
                            alert(message)
                        }
                    }
                )
            } else {
                alert('未获取到输入内容')
            }
        }

    </script>

</div>
{% endblock section_content %}
